home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Personal Computer World 2009 February
/
PCWFEB09.iso
/
Software
/
Linux
/
Kubuntu 8.10
/
kubuntu-8.10-desktop-i386.iso
/
casper
/
filesystem.squashfs
/
usr
/
sbin
/
pmi
< prev
next >
Wrap
Text File
|
2008-01-15
|
3KB
|
96 lines
#!/bin/bash
# This is the ACPI version of the shell version of PMI
# calling convention: pmi <event>
command="$1"
event="$2"
usage () {
echo "Usage: $0 query|action <event>" >&2
echo " $0 capabilities" >&2
exit 254
}
query () {
[ ! -z "$1" ] && event="$1"
case "$event" in
suspend|sleep)
if grep -q ' /host fuse' /proc/mounts; then
# Disallow suspend when we're mounting /
# from a loopback image on a fuse
# filesystem.
result=1
else
pm-is-supported --suspend && result=0 || result=1
fi
;;
hibernate)
if grep -q ' /host fuse' /proc/mounts || \
! swapon -s | tail -n +2 | awk '$2 == "file" { exit 1 }'; then
# Disallow hibernate when we're mounting /
# from a loopback image on a fuse
# filesystem, or when a swap file is active.
result=1
elif [ -f /var/run/do-not-hibernate ]; then
result=1
else
pm-is-supported --hibernate && result=0 || result=1
fi
;;
*)
result=1
echo "No such event found" >&2
;;
esac
}
run () {
case "$event" in
suspend|sleep)
[ -f /var/lock/acpisleep ] && exit 0
dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Suspend int32:0
;;
hibernate)
[ -f /var/lock/acpisleep ] && exit 0
[ -f /var/run/do-not-hibernate ] && echo "Default kernel has been upgraded" >&2 && exit 1
dbus-send --system --print-reply --dest=org.freedesktop.Hal /org/freedesktop/Hal/devices/computer org.freedesktop.Hal.Device.SystemPowerManagement.Hibernate
;;
restart)
[ -f /var/lock/acpisleep ] && exit 0
shutdown -r now
;;
shutdown)
[ -f /var/lock/acpisleep ] && exit 0
shutdown -h now
;;
esac
}
capabilities () {
for i in "hibernate" "suspend"; do
query $i
[ $result -eq 0 ] && caps="$caps $i"
done
echo $caps
}
case "$command" in
query)
query $event
exit $result
;;
action)
run $event
;;
capabilities)
capabilities
;;
*)
usage
;;
esac
exit 0